package com.shuwen.gcdj.controller.statistics;

import com.shuwen.gcdj.bean.conditionMonitoring.request.CenterTrendstabilityReq;
import com.shuwen.gcdj.bean.conditionMonitoring.request.StatisticMonitoringCriteriaReq;
import com.shuwen.gcdj.bean.conditionMonitoring.response.MonitoringPositionResp;
import com.shuwen.gcdj.bean.conditionMonitoring.response.StatisticCenterTrendStabilityResp;
import com.shuwen.gcdj.bean.conditionMonitoring.response.StatisticMonitoringBeamResp;
import com.shuwen.gcdj.bean.conditionMonitoring.response.StatisticTrendSmoothnessResp;
import com.shuwen.gcdj.bean.sysDictionary.response.SysDictionaryResp;
import com.shuwen.gcdj.common.annotation.JWTAuth;
import com.shuwen.gcdj.common.api.CommonResult;
import com.shuwen.gcdj.controller.AuthController;
import com.shuwen.gcdj.service.statistic.ConditionMonitoringService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author XYC
 */
@Api(tags = "状态监控中心")
@RestController
@RequestMapping("/conditionMonitoring")
@Slf4j
public class ConditionMonitoringController extends AuthController {

    @Autowired
    private ConditionMonitoringService conditionMonitoringService;

    @ApiOperation(value = "状态监控中心主梁/主结构位置")
    @PostMapping(value = "/getMonitoringPosition")
    @JWTAuth
    public CommonResult<List<MonitoringPositionResp>> getMonitoringPosition(@RequestBody @Valid StatisticMonitoringCriteriaReq req){
        return conditionMonitoringService.getMonitoringPosition(req);
    };


    @ApiOperation(value = "主梁")
    @PostMapping(value = "/getMainBeamAsync")
    @JWTAuth
    public CommonResult<List<StatisticMonitoringBeamResp>> getMainBeamAsync(@RequestBody @Valid StatisticMonitoringCriteriaReq req){
        return conditionMonitoringService.getMainBeamAsync(req);
    };


    @ApiOperation(value = "主结构")
    @PostMapping(value = "/getMainStructureAsync")
    @JWTAuth
    public CommonResult<List<StatisticMonitoringBeamResp>> getMainStructureAsync( @RequestBody @Valid StatisticMonitoringCriteriaReq req){
        return conditionMonitoringService.getMainStructureAsync(req);
    }


    @ApiOperation(value = "起升机构")
    @PostMapping(value = "/getLiftingStructureAsync")
    @JWTAuth
    public CommonResult<List<StatisticCenterTrendStabilityResp>> getLiftingStructureAsync(@RequestBody @Valid CenterTrendstabilityReq req, BindingResult bindingResult){
        return conditionMonitoringService.getLiftingStructureAsync(req);
    };

    @ApiOperation(value = "主梁趋势平稳度")
    @PostMapping(value = "/getMainBeamTrendSmoothnessAsync")
    @JWTAuth
    public CommonResult<List<StatisticTrendSmoothnessResp>> getMainBeamTrendSmoothnessAsync(@RequestBody @Valid CenterTrendstabilityReq req, BindingResult bindingResult){
        return conditionMonitoringService.getMainBeamTrendSmoothnessAsync(req);
    };

    @ApiOperation(value = "主结构趋势平稳度")
    @PostMapping(value = "/getMainStructureTrendSmoothnessAsync")
    @JWTAuth
    public CommonResult<List<StatisticTrendSmoothnessResp>> getMainStructureTrendSmoothnessAsync(@RequestBody @Valid CenterTrendstabilityReq req, BindingResult bindingResult){
        return conditionMonitoringService.getMainStructureTrendSmoothnessAsync(req);
    };

    @ApiOperation(value = "状态中心历史区间")
    @GetMapping(value = "/getSysDictionaryRespHistoryInterval")
    @JWTAuth
    public CommonResult<List<SysDictionaryResp>> getSysDictionaryRespHistoryInterval(){
        return CommonResult.success(conditionMonitoringService.getSysDictionaryRespHistoryInterval());
    }
}
